package com.zb_study.outputstream_;

import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStream01 {
    public static void main(String[] args) {

    }


    @Test
    public void writeFile() {
        String filePath = "e:\\a.txt";
        FileOutputStream fileOutputStream = null;
        try {
            //fileOutputStream = new FileOutputStream(filePath);
            fileOutputStream = new FileOutputStream(filePath, true);

            //fileOutputStream.write('H');

            String str = "he,world";

           // fileOutputStream.write(str.getBytes());

            fileOutputStream.write(str.getBytes(), 0, str.length());

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
